<template>
  <div>
    <CityHeader />
    <CitySearch :cities="cities" />
    <CityList :hotCities="hotCities" :cities="cities" :letter="letter" />
    <CityZimubiao :cities="cities" @change="handletterChange" />
  </div>
</template>
<script>
import CityHeader from "./components/header";
import CitySearch from "./components/search";
import CityList from "./components/list";
import CityZimubiao from "./components/zimubiao";
import axios from "axios";
export default {
  name: "City",
  data() {
    return {
      hotCities: [],
      cities: {},
      letter: "",
    };
  },
  components: {
    CityHeader,
    CitySearch,
    CityList,
    CityZimubiao,
  },
  methods: {
    GetCityList() {
      axios.get("/api/city.json").then(this.GetCityListsucc);
    },
    GetCityListsucc(res) {
      res = res.data;
      if (res.ret && res.data) {
        const data = res.data;
        this.hotCities = data.hotCities;
        this.cities = data.cities;
      }
    },
    handletterChange(letter) {
      this.letter = letter;
    },
  },
  mounted() {
    this.GetCityList();
  },
};
</script>

<style lang="stylus" scoped></style>
